#coding: utf-8


from twisted.internet import wxreactor
wxreactor.install()
from twisted.internet import reactor
import wx

from gui import userform
from server import vuser
import stock
INI_FILENAME = "config.ini"
     
class VehicleHunterApp(wx.App):
    def OnInit(self):
        config = stock.ConfigIni(INI_FILENAME)
        host = config.get("USER", "connectAddr", '127.0.0.1')
        port = int(config.get("USER", "connectPort", '14556'))
        config.save()
        connector = vuser.UserConnector(userform)
        connector.connect(host, port)
        self.form = userform.createMainForm(connector)
        return True
    
    def MainLoop(self):
        self.form.Show(True)
        self.form.Maximize()
        wx.App.MainLoop(self)
        
if __name__ == '__main__':
    app = VehicleHunterApp(0)
    reactor.registerWxApp(app)
    reactor.run()
    
    